package com.ruoyi.web.controller.miniapp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.miniapp.domain.MiniActivityReview;
import com.ruoyi.miniapp.service.IMiniActivityReviewService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 精彩回顾Controller
 * 
 * @author duantao
 * @date 2025-09-20
 */
@RestController
@RequestMapping("/miniapp/review")
public class MiniActivityReviewController extends BaseController
{
    @Autowired
    private IMiniActivityReviewService miniActivityReviewService;

    /**
     * 查询精彩回顾列表
     */
//    @PreAuthorize("@ss.hasPermi('miniapp:review:list')")
    @GetMapping("/list")
    public TableDataInfo list(MiniActivityReview miniActivityReview)
    {
        startPage();
        List<MiniActivityReview> list = miniActivityReviewService.selectMiniActivityReviewList(miniActivityReview);
        return getDataTable(list);
    }

    /**
     * 设置目录节点
     */
    @PreAuthorize("@ss.hasPermi('miniapp:review:edit')")
    @Log(title = "精彩回顾", businessType = BusinessType.UPDATE)
    @PostMapping("/setMenu")
    public AjaxResult setMenu(@RequestBody MiniActivityReview miniActivityReview)
    {
        return toAjax(miniActivityReviewService.updateMiniActivityReview(miniActivityReview));
    }


    /**
     * 导出精彩回顾列表
     */
    @PreAuthorize("@ss.hasPermi('miniapp:review:export')")
    @Log(title = "精彩回顾", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MiniActivityReview miniActivityReview)
    {
        List<MiniActivityReview> list = miniActivityReviewService.selectMiniActivityReviewList(miniActivityReview);
        ExcelUtil<MiniActivityReview> util = new ExcelUtil<MiniActivityReview>(MiniActivityReview.class);
        util.exportExcel(response, list, "精彩回顾数据");
    }

    /**
     * 获取精彩回顾详细信息
     */
//    @PreAuthorize("@ss.hasPermi('miniapp:review:query')")
    @GetMapping(value = "/{reviewId}")
    public AjaxResult getInfo(@PathVariable("reviewId") Long reviewId)
    {
        return success(miniActivityReviewService.selectMiniActivityReviewByActivityId(reviewId));
    }

    /**
     * 新增精彩回顾
     */
    @PreAuthorize("@ss.hasPermi('miniapp:review:add')")
    @Log(title = "精彩回顾", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MiniActivityReview miniActivityReview)
    {
        return toAjax(miniActivityReviewService.insertMiniActivityReview(miniActivityReview));
    }

    /**
     * 修改精彩回顾
     */
    @PreAuthorize("@ss.hasPermi('miniapp:review:edit')")
    @Log(title = "精彩回顾", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MiniActivityReview miniActivityReview)
    {
        return toAjax(miniActivityReviewService.updateMiniActivityReview(miniActivityReview));
    }

    /**
     * 删除精彩回顾
     */
    @PreAuthorize("@ss.hasPermi('miniapp:review:remove')")
    @Log(title = "精彩回顾", businessType = BusinessType.DELETE)
	@DeleteMapping("/{activityIds}")
    public AjaxResult remove(@PathVariable Long[] activityIds)
    {
        return toAjax(miniActivityReviewService.deleteMiniActivityReviewByActivityIds(activityIds));
    }
}
